package com.mygdx.game.Stage.Fight;

import com.badlogic.gdx.scenes.scene2d.Stage;
import com.mygdx.game.Stage.Fight.Card.*;

import java.util.ArrayList;

public class Cards {

    public ArrayList<Card> cards = new ArrayList<>();
    public ArrayList<Card> handCards = new ArrayList<>();
    public Card cardBack;

    Cards(){
        creatCards();
        getHandCards();
        generateCardBack();
    }

    public int creatCards(){
        for (int i=0;i<21;i++){
            //添加卡牌
            cards.add(new ExampleCard());
        }
        cards.add(new BloodAttackCard());
        cards.add(new BloodAttackCardPlus());
        cards.add(new BodyHitCardPlus());
        cards.add(new CleaveCard());
        cards.add(new CleaveCardPlus());
        cards.add(new NormalAttackCard());
        cards.add(new NormalAttackCardPlus());
        cards.add(new ShieldCard());
        cards.add(new ShieldCardPlus());
        return cards.size();
    }

    public ArrayList<Card> getHandCards(){
        for (int i=0;i<5;i++){
            handCards.add(drawCard());
        }
        return handCards;
    }

    public Card drawCard(){
        if (cards.size()<=0){
            return null;
        }
        int id = (int)(Math.random()*cards.size());
        Card card = cards.get(id);
        cards.remove(id);
        return card;
    }

    public void generateCardBack(){
        cardBack = new CardCardBack();
        cardBack.setCardPosition(5);
    }

    public boolean isCardsReady(){
        for (Card card:handCards){
            if ((int)card.x%300!=0)return false;
        }
        return true;
    }

}
